Skip to content

fix: mark generateIdentifierFromStoredProcedure functions as VOLATILE#12391

Open
vera wants to merge 3 commits into
IQSS:developfrom
vera:fix/generate-id-from-stored-procedure-volatile
Open

fix: mark generateIdentifierFromStoredProcedure functions as VOLATILE#12391
vera wants to merge 3 commits into
IQSS:developfrom
vera:fix/generate-id-from-stored-procedure-volatile

Conversation

@vera
Copy link
Copy Markdown
Contributor

@vera vera commented May 11, 2026

What this PR does / why we need it:

This PR makes two changes:

  • It updates the two example generateIdentifierFromStoredProcedure functions shown in the docs to be VOLATILE instead of IMMUTABLE.
  • It adds a Flyway migration for existing generateIdentifierFromStoredProcedure functions to make them VOLATILE.

The functions cannot be IMMUTABLE, because they would need to be "guaranteed to return the same results given the same arguments forever" [1], which neither of them are.

In the documented example functions, now() and nextval('datasetidentifier_seq') return different values over time, so the function's output changes even though it takes no arguments. In general, we can assume that any implementation of generateIdentifierFromStoredProcedure should return a different result every time you call it, because it's supposed to generate unique identifiers.

When the DB assumes the functions are IMMUTABLE, it may cache the function result and occasionally just return the same cached identifier over and over. This would cause the loop in generateIdentifierFromStoredProcedureIndependent to get stuck.

See also: my Zulip post, which has a bit more detail.

[1] https://www.postgresql.org/docs/current/xfunc-volatility.html

Which issue(s) this PR closes:

None

Special notes for your reviewer:

/

Suggestions on how to test this:

For confirming this bug, you could set up a Dataverse with a PID provider that uses "storedProcGenerated" and then create a number of datasets via API in quick succession.

Without the change in this PR, the "create dataset" API sometimes gets stuck and doesn't return a response.

With this change, it no longer gets stuck.

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

/

Is there a release notes update needed for this change?:

I added a short release note

Additional documentation:

/

@pdurbin pdurbin moved this to Ready for Triage in IQSS Dataverse Project May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready for Triage

Development

Successfully merging this pull request may close these issues.

2 participants